package net.togogo.annotation.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.sql.DataSource;

/**
 * @Autowired:可以对类的成员表变量，方法构造方法进行标注，让spring容器自动完成装配工作
 * @Repository 标记dao层
 */

@Repository("userDao")
public class UserDao {

    @Autowired
    private DataSource dataSource;

    @Value("迁都偶偶")
    private String name;

    @Value("18")
    private Integer age;

    @PostConstruct
    public void UserInit(){
        System.out.println("======对象初始化了=======");
    }

    @PreDestroy
    public void UserDestroy(){
        System.out.println("======对象销毁了=======");
    }

    public void saveUser(String user){
        System.out.println("=======保存用户信息=========");
        System.out.println("用户名称：" + name);
        System.out.println("用户年龄：" + age);
        System.out.println("用户信息：" + user);
        System.out.println("获取数据源信息：" + dataSource);
    }
}
